﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DAL;

namespace BLL
{
    public class ClsChiTieuThanhPhanHoaHocBus
    {
      public ClsChiTieuThanhPhanHoaHocInfo Info = new ClsChiTieuThanhPhanHoaHocInfo();
      public DataTable SelectAll()
      {
          ClsDataAccess oConnection = new ClsDataAccess();
          string strSql = @"SELECT * FROM ChiTieuThanhPhanHoaHoc";

          if (oConnection.ExecuteSelect(strSql))
          {
              oConnection.ODataTable.Columns.Add("STT");
              int i = 0;
              foreach (DataRow oDRow in oConnection.ODataTable.Rows)
              {
                  oDRow["STT"] = (i + 1);
                  i++;
              }
              return oConnection.ODataTable;
          }
          else return null;
      }
      public DataTable SelectQuyChuan()
      {
          ClsDataAccess oConnection = new ClsDataAccess();
          string strSql = @"SELECT MaQuyChuan FROM QuyChuan";

          if (oConnection.ExecuteSelect(strSql))
          {
              return oConnection.ODataTable;
          }
          else return null;
      }
      public bool Them()
      {
          string strSql = "EXECUTE InsertChiTieuThanhPhanHoaHoc'" + Info.MaQuyChuan + "','" + Info.DoPH + "','" + Info.CO2TuDo + "','" + Info.CO2LienHe
                                                            + "','" + Info.CO2XamThuc + "','" + Info.HCO3 + "','" + Info.OH + "','" + Info.CO3 + "','" + Info.Phenol
                                                            + "','" + Info.DoCungCa + "','" + Info.DoCungMg + "','" + Info.Cl + "','" + Info.SO4 + "','" + Info.Fe2
                                                            + "','" + Info.Fe3 + "','" + Info.F + "','" + Info.H2S + "','" + Info.HCCuaAxitSilicic + "','" + Info.PO4
                                                            + "','" + Info.NO2 + "','" + Info.NO3 + "','" + Info.NH4 + "','" + Info.DO + "','" + Info.COD + "','" + Info.BOD
                                                            + "','" + Info.CN + "','" + Info.Cd + "','" + Info.Ni + "','" + Info.Cr3 + "','" + Info.Cr6 + "','" + Info.Hg
                                                            + "','" + Info.Pd + "','" + Info.Asen + "','" + Info.Be + "','" + Info.Sb + "','" + Info.Se + "','" + Info.V + "','" + Info.Sn
                                                            + "','" + Info.Zn + "','" + Info.Cu + "','" + Info.Mn + "','" + Info.DauMo + "','" + Info.ChatTayRua + "','" 
                                                            + Info.TongHoaChatBVTV + "','" + Info.DDT +"'";
          ClsDataAccess oConnection = new ClsDataAccess();
          return (oConnection.ExecuteStoredProcedure(strSql));
      }

      public bool Sua()
      {
          string strSql = "EXECUTE UpdateChiTieuThanhPhanHoaHoc '" + Info.MaQuyChuan + "','" + Info.DoPH + "','" + Info.CO2TuDo + "','" + Info.CO2LienHe
                                                            + "','" + Info.CO2XamThuc + "','" + Info.HCO3 + "','" + Info.OH + "','" + Info.CO3 + "','" + Info.Phenol
                                                            + "','" + Info.DoCungCa + "','" + Info.DoCungMg + "','" + Info.Cl + "','" + Info.SO4 + "','" + Info.Fe2
                                                            + "','" + Info.Fe3 + "','" + Info.F + "','" + Info.H2S + "','" + Info.HCCuaAxitSilicic + "','" + Info.PO4
                                                            + "','" + Info.NO2 + "','" + Info.NO3 + "','" + Info.NH4 + "','" + Info.DO + "','" + Info.COD + "','" + Info.BOD
                                                            + "','" + Info.CN + "','" + Info.Cd + "','" + Info.Ni + "','" + Info.Cr3 + "','" + Info.Cr6 + "','" + Info.Hg
                                                            + "','" + Info.Pd + "','" + Info.Asen + "','" + Info.Be + "','" + Info.Sb + "','" + Info.Se + "','" + Info.V + "','" + Info.Sn
                                                            + "','" + Info.Zn + "','" + Info.Cu + "','" + Info.Mn + "','" + Info.DauMo + "','" + Info.ChatTayRua + "','"
                                                            + Info.TongHoaChatBVTV + "','" + Info.DDT + "'";
          ClsDataAccess oConnection = new ClsDataAccess();
          return (oConnection.ExecuteStoredProcedure(strSql));

      }

      public bool Xoa()
      {
          string strSql = "EXECUTE DeleteChiTieuThanhPhanHoaHoc '" + Info.MaQuyChuan + "'";
          ClsDataAccess oConnection = new ClsDataAccess();
          return (oConnection.ExecuteStoredProcedure(strSql));

      }
    }

    }
